<!DOCTYPE html>
<html lang="en">
    <head>
        <title>新增保养任务</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="../css/global.css" rel="stylesheet">
        <link rel="stylesheet" href="../css/iconfont/iconfont.css">
        <link rel="stylesheet" href="../css/addPatrolPage.css">
        <script src="../js/vue.js"></script>
        <script src="../js/axios.js"></script>
        <link rel="stylesheet" href="../css/nutui/dist/nutui.css">
        <script src="../css/nutui/dist/nutui.js"></script>
    </head>
    <body>
        <div id="app">
            <div class="app_header">
                <div class="app_headerLeft" @click="back">
                    <span class="iconfont icon-arrow-left-bold"></span>
                </div>
                <div class="app_headerTitle">新增保养</div>
            </div>
            <div class="app_main">
                <div class="app_mainItem">
                    <div class="app_mainItem_label">名称<span>*</span></div>
                    <div class="app_mainItem_inp">
                        <input type="text" v-model="form.taskName" placeholder="请输入">
                    </div>
                </div>
                <div class="app_mainItem">
                    <div class="app_mainItem_label">保养设备<span>*</span></div>
                    <div class="app_mainItem_inp" @click="rangeShow = true">
                        <div :style="{color:form.range == '' ?'#D1D1D1':'#000'}">{{ form.range || '请选择'
                            }}<span class="iconfont icon-arrow-right-bold"></span></div>
                    </div>
                </div>
                <div class="app_mainItem">
                    <div class="app_mainItem_label">保养内容<span>*</span></div>
                    <div class="app_mainItem_inp" @click="contentShow = true">
                        <div :style="{color:form.content == '' ?'#D1D1D1':'#000'}">{{ form.content || '请选择'
                            }}<span class="iconfont icon-arrow-right-bold"></span></div>
                    </div>
                </div>
                <div class="app_mainItem">
                    <div class="app_mainItem_label">保养人<span>*</span></div>
                    <div class="app_mainItem_inp" @click="people1Show = true">
                        <div :style="{color:form.people == '' ?'#D1D1D1':'#000'}">{{ form.people || '请选择'
                            }}<span class="iconfont icon-arrow-right-bold"></span></div>
                    </div>
                </div>
                <div class="app_mainItem">
                    <div class="app_mainItem_label">开始时间<span>*</span></div>
                    <div class="app_mainItem_inp" @click="isVisibleStart = true">
                        <div :style="{color:form.startTime == '' ?'#D1D1D1':'#000'}">{{ form.startTime || '请选择'
                            }}<span class="iconfont icon-arrow-right-bold"></span></div>
                    </div>
                </div>
                <div class="app_mainItem">
                    <div class="app_mainItem_label">截止时间<span>*</span></div>
                    <div class="app_mainItem_inp" @click="isVisibleEnd = true">
                        <div :style="{color:form.endTime == '' ?'#D1D1D1':'#000'}">{{ form.endTime || '请选择'
                            }}<span class="iconfont icon-arrow-right-bold"></span></div>
                    </div>
                </div>
    
                <div class="app_mainItem2">
                    <div class="app_mainItem_label">备注说明</div>
                    <div class="app_mainItem_inp">
                        <nut-textbox v-model="form.note" :max-num="100"></nut-textbox>
                    </div>
                </div>
                <nut-button block>确定</nut-button>
            </div>
            <!-- 保养设备弹窗 -->
            <nut-popup v-model="rangeShow" position="bottom" round :style="{ height: '40%' }">
                <div class="popupTitle">
                    <div class="left"></div>
                    <div class="title">保养设备</div>
                </div>
                <div class="popupMain">
                    <div class="popupMainItem" v-for="(item, index) in list" :key="index"
                        @click="selectType(item,3)">
                        {{item.name}}</div>
                </div>
            </nut-popup>
            <!-- 保养内容弹窗 -->
            <nut-popup v-model="contentShow" position="bottom" round :style="{ height: '40%' }">
                <div class="popupTitle">
                    <div class="left"></div>
                    <div class="title">保养内容</div>
                </div>
                <div class="popupMain">
                    <div class="popupMainItem" v-for="(item, index) in contentList" :key="index"
                        @click="selectType(item,1)">
                        {{item.name}}</div>
                </div>
            </nut-popup>
            <!-- 保养人弹窗 1 -->
            <nut-popup v-model="people1Show" position="bottom" round :style="{ height: '20vh' }">
                <div class="popupTitle">
                    <div class="title">保养人</div>
                </div>
                <div class="popupMain" style="height: calc(20vh - 50px)!important;">
                    <div class="popupMainList">
                        <div class="popupMainListItem">
                            <div>负责人</div>
                            <nut-radio v-model="radioVal" :label="'负责人'"></nut-radio>
                        </div>
                        <div class="popupMainListItem">
                            <div>其他</div>
                            <nut-radio v-model="radioVal" :label="'其他'"></nut-radio>
                        </div>
                    </div>
                    <div class="app_mainItem" v-if="radioVal == '负责人'">
                        <div class="app_mainItem_label">保养人<span>*</span></div>
                        <div class="app_mainItem_inp">
                            <div :style="{color:form.people == '' ?'#D1D1D1':'#000'}">{{ form.people || '请选择'
                                }}<span class="iconfont icon-arrow-right-bold"></span></div>
                        </div>
                    </div>
                    <div class="app_mainItem" v-if="radioVal == '其他'">
                        <div class="app_mainItem_label">保养人<span>*</span></div>
                        <div class="app_mainItem_inp" @click="people2Show = true, people1Show = false">
                            <div :style="{color:form.people == '' ?'#D1D1D1':'#000'}">{{ form.people || '请选择'
                                }}<span class="iconfont icon-arrow-right-bold"></span></div>
                        </div>
                    </div>
                    <!-- <div class="popupMain"></div> -->
                </div>
            </nut-popup>
            <!-- 巡检人弹窗 2 -->
            <nut-popup v-model="people2Show" position="bottom" round :style="{ height: '40%' }">
                <div class="popupTitle">
                    <div class="left" @click="people1Show = true, people2Show = false">
                        <span class="iconfont icon-close-bold"></span>
                    </div>
                    <div class="title">选择人员</div>
                </div>
                <div class="popupMain">
                    <div class="popupMainItem" v-for="(item, index) in peopleList" :key="index" @click="selectType(item,2)">
                        {{item.name}}</div>
                </div>
            </nut-popup>
            <!-- 开始时间选择 -->
            <nut-datepicker :is-visible="isVisibleStart" type="date" title="请选择日期" :is-show-chinese="false"
                @close="switchPickerStart('isVisibleStart')" @choose="setChooseValueStart">
            </nut-datepicker>
            <!-- 截止时间选择 -->
            <nut-datepicker :is-visible="isVisibleEnd" type="date" title="请选择日期" :is-show-chinese="false"
                @close="switchPickerEnd('isVisibleEnd')" @choose="setChooseValueEnd">
            </nut-datepicker>
        </div>
        <script>
            var vm = new Vue({
            el: '#app',
            data: {
                radioVal: '',
                isVisibleStart: false,
                isVisibleEnd: false,
                rangeShow: false,
                contentShow: false,
                people1Show: false,
                people2Show: false,
                peopleList: [
                    { id: 1, name: '张三1111' },
                    { id: 2, name: '张三2222' },
                    { id: 3, name: '张三3333' },
                    { id: 4, name: '张三4444' },
                    { id: 5, name: '张三5555' },
                ],
                contentList: [
                    { id: 1, name: '巡检内容111' },
                    { id: 2, name: '巡检内容222' },
                    { id: 3, name: '巡检内容333' },
                    { id: 4, name: '巡检内容444' },
                    { id: 5, name: '巡检内容555' },
                    { id: 6, name: '巡检内容666' },
                ],
                list: [
                    { id: 1, name: '保养设备111' },
                    { id: 2, name: '保养设备222' },
                    { id: 3, name: '保养设备333' },
                    { id: 4, name: '保养设备444' },
                    { id: 5, name: '保养设备555' },
                    { id: 6, name: '保养设备666' },
                ],
                form: {
                    taskName: '',
                    range: '',
                    content: '',
                    people: '',
                    startTime: '',
                    endTime: '',
                    note: ''
                }
            },
            mounted() { },
            watch: {
                radioVal(val){
                    if (val == '负责人') {
                        this.form.people = '负责人1111'
                        this.people1Show = false
                    }else {
                        this.form.people = ''
                    }
                }
            },
            methods: {
                back() {
                    window.history.go(-1);
                },
                switchPickerStart(param) {
                    this[`${param}`] = !this[`${param}`];
                },
                setChooseValueStart(param) {
                    this.form.startTime = param[3];
                },
                switchPickerEnd(param) {
                    this[`${param}`] = !this[`${param}`];
                },
                setChooseValueEnd(param) {
                    this.form.endTime = param[3];
                },
                selectType(data, val) {
                    if (val == 1) {
                        this.form.content = data.name
                        this.contentShow = false
                    } else if (val == 2) {
                        this.form.people = data.name
                        this.people2Show = false
                    } else if (val == 3){
                        this.form.range = data.name
                        this.rangeShow = false
                    }
                },
            }
        })
        </script>
    </body>
</html>